package cn.wygandwdn.core.loadbalancer;

import com.alibaba.nacos.api.naming.pojo.Instance;

import java.util.List;
import java.util.Random;

/**
 * @description:    随机负载均衡机制,随机返回服务地址
 * @author: WYG
 * @time: 2021/10/25 21:02
 */

public class RandomLoadBalancer implements LoadBalancer {
    @Override
    public <T> T select(List<T> instances) {
        Random random = new Random();
        return instances.get(random.nextInt(instances.size()));
    }
}
